package com.niiwoo.civet.trade.service.dubbo.lend;

import com.alibaba.dubbo.config.annotation.Service;
import com.niiwoo.civet.trade.dto.common.*;
import com.niiwoo.civet.trade.service.lend.ProjectLendDubboService;
import com.niiwoo.civet.trade.service.local.lend.ProjectLendLocalService;
import com.niiwoo.tripod.provider.exception.BizException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 满标放款处理
 * @author liaojunjun
 *
 */
@Service(version = "1.0.0")
public class ProjectLendDubboServiceImpl implements ProjectLendDubboService {

	private static final Logger logger = LoggerFactory.getLogger(ProjectLendDubboServiceImpl.class);
	
	@Autowired
	private ProjectLendLocalService projectLendLocalService;

	@Override
	public void lendResultNotify(List<BathTransactionNotifyDTO> lendNotifyDTOList) {
		projectLendLocalService.lendResultNotify(lendNotifyDTOList);
	}

	@Override
	public LendOrderDTO queryLendOrderByWithdrawOrderId(Long withdrawOrderId) {
		return projectLendLocalService.queryLendOrderByWithdrawOrderId(withdrawOrderId);
	}

	public void bankLendResultQueryJob() {
		projectLendLocalService.bankLendResultQueryJob();
	}

	public void bankLendFailedJob() {
		projectLendLocalService.bankLendFailedJob();
	}

	public void bankProjectStatusJob() {
		projectLendLocalService.bankProjectStatusJob();
	}

	public void accountingStatusJob() {
		projectLendLocalService.accountingStatusJob();
	}

	public void investRankStatusJob() {
		projectLendLocalService.investRankStatusJob();
	}

	public void borrowerPrizeStatusJob() {
		projectLendLocalService.borrowerPrizeStatusJob();
	}

	public void investorPrizeStatusJob() {
		projectLendLocalService.investorPrizeStatusJob();
	}
	
	public void projectRaiseRateStatusJob() {
		projectLendLocalService.projectRaiseRateStatusJob();
	}

	public void packageRaiseRateStatusJob() {
		projectLendLocalService.packageRaiseRateStatusJob();
	}

	@Override
	public void signContract(Long projectId) {
		try {
			logger.info("mediacyLoanContractCompensate...start");
			projectLendLocalService.lendContractHandler(projectId);
			logger.info("mediacyLoanContractCompensate...end");
		} catch (BizException e) {
			logger.error("mediacyLoanContractCompensateBizException", e);
			e.printStackTrace();
		} catch (Exception e) {
			logger.error("mediacyLoanContractCompensateException", e);
			e.printStackTrace();
		}
	}

}
